/*
 * EnrollActivity.java
 * business
 *
 * Created by chentao on 2017/4/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.main.discovery.enroll;

import android.app.Activity;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.data.model.ArticleModel;
import com.yidiandao.business.data.recyclertype.Article;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * Activity.
 */
public class EnrollActivity extends BaseActivity {

    private EnrollFragment mEnrollFragment;

    public static void actionStart(Activity activity, Article.Extra article) {
        Intent intent = new Intent(activity, EnrollActivity.class);
        intent.putExtra(Intents.EXTRA_ARTICLE_EXTRA, article);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mEnrollFragment = (EnrollFragment) getSupportFragmentManager().findFragmentById(R.id.container_apply);

        if (mEnrollFragment == null) {
            mEnrollFragment = EnrollFragment.getInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), mEnrollFragment, R.id.container_apply);
        }

    }

    @Override
    protected void initPresenter() {
        Article.Extra articleExtra = getIntent().getExtras().getParcelable(Intents.EXTRA_ARTICLE_EXTRA);
        new EnrollPresenter(mEnrollFragment, articleExtra, new ArticleModel());
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_enroll;
    }
}
